package com.lg.online_shop.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lg.online_shop.entity.Address;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AddressMapper extends BaseMapper<Address> {
//      根据userId获取地址
    @Select("select * from address where user_id = #{userId}")
    List<Address> selectAddressByUserId(Integer userId);

//       新增地址
    @Insert("insert into address(address_name,user_id,phone,addressee) values(#{addressName},#{userId},#{phone},#{addressee})")
    int addAddress(String addressName, Integer userId, String phone, String addressee);

//    更改地址
    @Update("update address set address_name = #{addressName},phone = #{phone},addressee = #{addressee} where id = #{id}")
     Integer updateAddress(Integer id, String addressName, String phone, String addressee);


//    获取地址列表
    @Select("select * from address where user_id = #{uId}")
    List<Address> selectByUId(Long uId);
}
